<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>Title</title>
	</head>

	<body>
		<div>
			<a href="http://www.baidu.com" onclick="turn();return false;">切换</a>

			<a href="http://www.baidu.com" onclick="return turn();">切换</a>
			<br>
			<img id="i1" src="images/bg3.jpg" width="400" onclick="turn()">

			<script>
				function turn() {
					//获取img对象
					var img = document.getElementById("i1");
					//换图片
					img.src = "images/bg2.jpg";
					return false;
				}
			</script>
		</div>

		<div>
			<a href="images/bg2.jpg" onclick="return turn1(this);">切换</a>
			<br>
			<img id="i2" src="images/bg3.jpg" width="400">

			<script>
				function turn1(link) {
					//获取img对象
					var img = document.getElementById("i2");
					//换图片
					img.src = link.href;
					return false;
				}
			</script>
		</div>

	</body>

</html>